import observe from "./observe";

function defineReactiveData(data, key, value){

    // 还要走一遍 递归调用 defineReactiveData observe
    observe(value)
    // console.log('递归reactive', value)

    Object.defineProperty(data, key, {
        get(){
            console.log('响应式数据获取',value)
            return value
        },
        set(newValue){
            console.log('响应式数据设置',newValue);
            if(newValue === value) return
            observe(newValue)
            value = newValue
        }
    })
}

export default defineReactiveData